package com.lanou.musicbox.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.lanou.musicbox.fragment.AlbumFragment;
import com.lanou.musicbox.fragment.PlaylistFragment;
import com.lanou.musicbox.fragment.SingerFragment;
import com.lanou.musicbox.fragment.SingleFragment;

import java.util.ArrayList;

/**
 * Created by dllo on 15/10/24.
 */
public class EnterTheSeekMusicAdapter extends FragmentPagerAdapter{
    private String[] titles = {"推荐","排行榜","歌单","歌手"};
    private ArrayList<Fragment> fragments;

    public EnterTheSeekMusicAdapter(FragmentManager fm) {
        super(fm);
        initFragment();
    }

    private void initFragment() {
        fragments = new ArrayList<>();
        fragments.add(new SingleFragment());
        fragments.add(new SingerFragment());
        fragments.add(new AlbumFragment());
        fragments.add(new PlaylistFragment());
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
